package com.speedy.course.base

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
import androidx.viewpager2.adapter.FragmentStateAdapter

class BasePagerAdapter(
    fragmentManager: FragmentManager,
    lifecycle: Lifecycle,
    initScope:(list:MutableList<Fragment>)->Unit
) : FragmentStateAdapter(fragmentManager, lifecycle) {

    private val fragmentList = mutableListOf<Fragment>()

    init {
        initScope.invoke(fragmentList)
    }

    override fun getItemCount(): Int {
        return fragmentList.size
    }

    override fun createFragment(position: Int): Fragment {
        return fragmentList[position]
    }

}